package com.lizhi.yun.system.stand.handler;/**
 * @program: sfrobot-html
 * @name AssessHandler
 * @description: 康复评估
 * @author: lizhi
 * @create: 2020-05-08 16:19
 */

import com.lizhi.client.RestClientService;
import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.common.yun.enums.ServiceEnum;
import com.lizhi.utils.json.SamJsonUtil;
import com.lizhi.yun.base.BaseHandler;
import com.lizhi.yun.base.common.RoleOrganUtils;
import com.lizhi.yun.db.dao.UppUserDao;
import com.lizhi.yun.db.pojo.UppUserPOJO;
import com.lizhi.yun.system.stand.enums.StandServiceEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 *@program: sfrobot-html
 *@name AssessHandler
 *@description: 康复评估
 *@author: lizhi
 *@create: 2020-05-08 16:19
 */
@Slf4j
@Service
public class AssessHandler extends BaseHandler {

    @Resource
    private UppUserDao uppUserDao;

    @Resource
    private RestClientService restClientService;

    /**
     *功能描述 查询所有的评估信息
     * @author lizhi
     * @date 2020/6/4
     * @param map:
     * @return com.lizhi.common.entity.ListResult<com.lizhi.db.pojo.StandPtInfoPOJO>
     */
    public ListResponseResult doMain(Map<String, Object> map, HttpServletRequest request) {
        String userAcct = request.getHeader("userAcct");
        UppUserPOJO uppUserPOJO = uppUserDao.selectById(userAcct);
        /*判断医院*/
        map.put("hospitalIds", RoleOrganUtils.listOrganIds(uppUserPOJO.getOrganIds()));

        String result = restClientService.postStringToService(StandServiceEnum.HBSF_STAND_ASSESS_INFO.getEnName(), StandServiceEnum.HBSF_STAND_ASSESS_INFO.getEnValue(), SamJsonUtil.toJson(map));
        return SamJsonUtil.toObject(result, ListResponseResult.class);
    }

    /**
     * 根据id查询评估信息
     * @param assId
     * @return
     */
    public ListResponseResult selectById(String assId, String hospitalId, String hospitalSystemId){
        Map<String, Object> map = new HashMap<>();
        map.put("assId", assId);
        map.put("hospitalId", hospitalId);
        map.put("hospitalSystemId", hospitalSystemId);
        String result = restClientService.postStringToService(ServiceEnum.HBSF_YUN.getEnName(), ServiceEnum.HBSF_YUN.getEnValue(), SamJsonUtil.toJson(map));
        return SamJsonUtil.toObject(result, ListResponseResult.class);
    }
}
